package com.lw.syn;

import java.util.ArrayList;

/**
 * @author LW
 * @2020/8/18 11:02
 */
//线程不安全的集合
public class UnsafeList {

    public static void main(String[] args) throws InterruptedException {
        ArrayList<Object> list = new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            new Thread(()->{
                //集合无法全部被线程记录
                list.add(Thread.currentThread().getName());
            }).start();
        }
        Thread.sleep(100);
        System.out.println(list.size());

    }
}

